home *** CD-ROM | disk | FTP | other *** search
- Path: argonet.co.uk!argbd86
- From: Charlotte Tomlinson <eeyore@argonet.co.uk>
- Newsgroups: comp.lang.c++
- Subject: Linked lists - will this work?
- Date: Fri, 05 Apr 1996 15:09:41
- Organization: UnipalmPIPEX server (post doesn't reflect views of UnipalmPIPEX
- Distribution: world
- Message-ID: <internews46BA23486F@argonet.co.uk>
- Reply-To: Charlotte Tomlinson <eeyore@argonet.co.uk>
- NNTP-Posting-Host: ai161.du.pipex.com
- X-Newsreader: VTi Voyager InterNews 0.15 for Acorn RISC OS (Patched by RA)
-
- Hi all,
-
- I posted a few days ago, and got several varied answers to my list problem
- (thanks, everyone). But I want to check if what I am considering doing
- will work and is reasonable sensible.
-
- I have implemented a template doubly linked list, the backbones of which
- is as follows:
-
- template <class T> class node
- {
- public:
- T data;
- node<T> *next;
- node<T> *prev;
- /*other functions*/
- };
-
- template <class T> class dllist : public node<T>
- {
- node<T> *start, *end;
- void copy(const dllist<T>);
-
- public:
- /*fns snipped*/
- };
-
-
- If I implemented a new member fn for dllist along the lines of:
-
- void dllist::iterate(T (*fptr)(T))
- {
- node<T> *temp;
- temp=getstart();
- while(temp)
- {
- temp->change(f(temp->getinfo));
- temp=temp->next;
- }
- }
-
- Would that have the effect I require, of taking a function which takes a T
- as its argument and performing that over the list? If it would do that,
- would it be reasonable 'safe' to use it also for functions that do not
- actually change the data in their body, but return the value passed after,
- say, printing it?
-
- Many thanks in advance.
-
-
-
- ... Windows? I saw through them!
- --
- -----------------------------------------------------------------------------
- | Charlotte Tomlinson | Mediocrity know nothing higher than itself, |
- | eeyore@argonet.co.uk | but talent instantly recognises genius. |
- |---------------------------------------------------------------------------|
- --------- Now WWWebbed up at http://www.argonet.co.uk/users/eeyore/ ---------
-
-